package iammry.com.base;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Window;

import com.lidroid.xutils.ViewUtils;


/**
 * @data 2016-10-25
 * @author kim
 * @TODO 基类 
 */
public abstract class BaseActivity extends FragmentActivity {

	public Context context;
	protected BaseActivity activity;

	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		
		/*getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);*/
		
		context = this;
		// wake up scree

		activity=BaseActivity.this;
		initView();
		
		initData();
		initEvent();


	}


	public void onResume() {
		super.onResume();
		
	}

	public void onPause() {
		super.onPause();
		
		
	}

	
	protected abstract void initView();

	
	protected void initData() {

	}

	
	protected void initEvent() {

	}

	/**
	 * 璁剧疆甯冨眬
	 * 
	 * @param activity
	 * @param layoutId
	 */
	protected void setLayout(BaseActivity activity, int layoutId) {
		this.activity = activity;
		setContentView(layoutId);
		ViewUtils.inject(this.activity);
	}

	
	protected void startActivity(Class<?> cls) {
		startActivity(cls, null);
	}

	
	protected void startActivity(Class<?> cls, Bundle bundle) {
		Intent intent = new Intent();
		intent.setClass(this, cls);
		if (bundle != null) {
			intent.putExtra("bundle", bundle);
		}
		startActivity(intent);
	}

}
